Date.CultureInfo.firstDayOfWeek=1; // 配置时间的第一天时周一
Array.prototype.remove = function(b) {
    var a = this.indexOf(b);
    if (a >= 0) {
        this.splice(a, 1);
        return true;
    }
    return false;
};

(function() {
    var instance = openerp;
    var _t = instance.web._t;
    var _lt = instance.web._lt;
    var QWeb = instance.web.qweb;
    /*******************************
     * 控制只读字段的权限
     *
     */
    instance.web.form.FieldMany2One.include({
        init:function () {
            var self = this;
            this._super.apply(this, arguments);
            //设置FieldMany2One字段(下拉框)的最大选择数量为14
            this.limit = 14 ;
            if(this.readonly != undefined ){
                this.readonly = true;
            }else{
                //初始化的时候就去做可编辑权限的检查，这时候一般都是只读状态
                if(this.options.readonly != undefined){
                    var groups = [] ;
                    if(this.options.editableGroups != undefined){
                        var Users = new openerp.web.Model('res.users');
                        //当前用户是否存在于任意指定的用户组中
                        Users.call('is_in_any_groups', [this.options.editableGroups]).done(function(is_in_groups) {
                            //如果不存在于指定的用户组中，设置只读标识
                            if (!is_in_groups) {
                                self.readonly = true;
                            }
                        });
                    }
                }
            }
        },

        render_editable: function () {
            this._super.apply(this, arguments);
            //如果为只读字段
            if(this.readonly){
                //设置只读的属性
                this.set({"effective_readonly":true});

            }


        }
    });

    //修正odoo自定义view_mode不会取得view_id的问题
    instance.web.ViewManagerAction.include({
        init: function(parent, action) {
            var self = this;
            if (!action.views[0][0] && action.view_id){
                if (action.views[0][1] == action.view_mode){
                    action.views[0][0] = action.view_id[0]
                }
            }
            return this._super.apply(this, arguments);
        }
    });


    instance.web.SearchView.include({
        //设置搜索框在列表,看板,图表,日历视图中默认展开
        start: function(){
            var self = this;
            this._super.apply(this, arguments);
            var view_manager = this.getParent();
            while (!(view_manager instanceof instance.web.ViewManager) &&
                    view_manager && view_manager.getParent) {
                view_manager = view_manager.getParent();
            }
            if (view_manager) {
                this.view_manager = view_manager;
                view_manager.on('switch_mode', this, function (e) {
                    self.drawer.toggle(_.contains(['list', 'graph', 'kanban','calendar'], e));
                });
            }
        },
        //解决odoo搜索框不会自动去除搜索条件前后空格问题
        setup_global_completion: function () {
            var self = this;
            this.autocomplete = new instance.web.search.AutoComplete(this, {
                source: this.proxy('complete_global_search'),
                select: this.proxy('select_completion'),
                delay: 0,
                get_search_string: function () {
                    var text = self.$('div.oe_searchview_input').text();
                    text = text.replace(/(^\s*)|(\s*$)/g,'');
                    return text;
                },
                width: this.$el.width(),
            });
            this.autocomplete.appendTo(this.$el);
        }
    });

    instance.web.ListView.include({
        /**
         * 检查是否可以删除
         * 在tree节点上增加一个deletable属性，用python表达式
         * @param record
         * @returns boolean
         */
        check_deletable: function(record){
            var context = _.extend({}, record.attributes, {
                uid: this.session.uid,
                current_date: new Date().toString('yyyy-MM-dd')
                // TODO: time, datetime, relativedelta
            });
            result = py.evaluate(this.deletable_expression, context).toJSON();
            return result;
        },

        start: function(){
            var model_name = this.dataset._model.name
            var Users = new openerp.web.Model('res.users');
            var self = this;
            //当前用户是否存在于任意指定的用户组中
            Users.call('is_perm_export', [model_name]).done(function(is_perm_export) {
                //如果不存在于指定的用户组中，设置只读标识
                self.is_perm_export = is_perm_export;
            });
            return this._super(parent);
        },

        /*******************************
         * 导出的html页面添加flag标签，用于控制是否隐藏导出按钮
         * 在模板Sidebar中增加了是否是管理员的判断，如果不是管理员则判断flag是否不等于Export进行html按钮的渲染
         * 如果是管理员的话，则略过flag检查，全部的html按钮都进行渲染
         * ** 如果能做到Sidebar模板中判断当前用户权限就更好了
         *
         * 增加子list视图是否可删除的功能(如deletable="id=1")
         */
        load_list: function () {
            var self = this;
            // Sidebar的导出按钮添加标签flag标识
            if (!this.sidebar && this.options.$sidebar) {
                this.sidebar = new instance.web.Sidebar(this);
                this.sidebar.appendTo(this.options.$sidebar);
                this.sidebar.add_items('other', _.compact([
                    //{label: _t("Export"), flag: 'Export', callback: this.on_sidebar_export},
                    //暂时不能解决用户导出权限判断问题，改用arch增加export属性来控制某些页面不能导出
                    self.is_action_enabled('export') && self.is_perm_export && {label: _t("Export"), callback: this.on_sidebar_export},
                    self.is_action_enabled('delete') && {label: _t('Delete'), callback: this.do_delete_selected}
                ]));
                //---- 判断菜单是否允许显示，不显示的菜单删除掉
                var options = {};
                try{
                    if (self.fields_view.arch.attrs.options) {
                        options = py.eval(self.fields_view.arch.attrs.options);
                    }
                }
                catch(error){
                    console.log('view "' + self.fields_view.name + '"的options格式错误:"' + self.fields_view.arch.attrs.options + '"，需要标准json格式.');
                }
                var remove_menus = function(toolbar, menu_type){
                    for (var i = toolbar[menu_type].length - 1; i >= 0; i --){
                        var menu = toolbar[menu_type][i];
                        if (menu.context){
                            try{
                                var menu_context = py.eval(menu.context);
                                if (menu_context['menu_judge_view_id']){
                                    if (menu_context['menu_judge_view_id'] != options['menu_judge_view_id']){
                                        toolbar[menu_type].remove(menu)
                                    }
                                }
                            }
                            catch(error){
                                console.log('菜单 "' + menu.display_name + '"的context格式错误:"' + menu.context + '"，需要标准的json格式.');
                            }
                        }
                    }
                };
                for (var menu_type in this.fields_view.toolbar){
                    if (this.fields_view.toolbar[menu_type] && this.fields_view.toolbar[menu_type].length > 0){
                        remove_menus(this.fields_view.toolbar, menu_type);
                    }
                }
                //---- end 判断菜单是否允许显示

                this.sidebar.add_toolbar(this.fields_view.toolbar);
                this.sidebar.$el.hide();
            }
            this._super.apply(this, arguments);
            //取得是否可编辑的表达式
            if (this.fields_view.arch.attrs.deletable!=undefined && this.fields_view.arch.attrs.deletable){
                this.deletable_expression = py.parse(py.tokenize(this.fields_view.arch.attrs.deletable));
            }else{
                this.deletable_expression=py.parse(py.tokenize('1==1'));
            }
        },
        //修正可编辑listView的某个字段存在按钮时无法进入编辑模式的问题  @正翔 提供解决方案
        resize_field: function (field, cell) {
            var $cell = $(cell);

            if ($cell.outerHeight() <= 0){
                return;
            }

            field.set_dimensions($cell.outerHeight(), $cell.outerWidth());
            field.$el.css({top: 0, left: 0}).position({
                my: 'left top',
                at: 'left top',
                of: $cell
            });
            if (field.get('effective_readonly')) {
                field.$el.addClass('oe_readonly');
            }
            if(field.widget == "handle")
                field.$el.addClass('oe_list_field_handle');
        }
    });

    instance.web.FormView.include({
        load_form: function(){
            var self = this;
            this.$sidebar = this.options.$sidebar || this.$el.find('.oe_form_sidebar');
            if (!this.sidebar && this.options.$sidebar) {
                this.sidebar = new instance.web.Sidebar(this);
                this.sidebar.appendTo(this.$sidebar);
                if (this.fields_view.toolbar) {
                    var options = {};
                    try{
                        if (self.fields_view.arch.attrs.options) {
                            options = py.eval(self.fields_view.arch.attrs.options);
                        }
                    }
                    catch(error){
                        console.log('view "' + self.fields_view.name + '"的options格式错误:"' + self.fields_view.arch.attrs.options + '"，需要标准json格式.');
                    }
                    var remove_menus = function(toolbar, menu_type){
                        for (var i = toolbar[menu_type].length - 1; i >= 0; i --){
                            var menu = toolbar[menu_type][i];
                                if (menu.context){
                                try{
                                    var menu_context = py.eval(menu.context);
                                    if (menu_context['menu_judge_view_id']){
                                        if (menu_context['menu_judge_view_id'] != options['menu_judge_view_id']){
                                            toolbar[menu_type].remove(menu)
                                        }
                                    }
                                }
                                catch(error){
                                    console.log('菜单 "' + menu.display_name + '"的context格式错误:"' + menu.context + '"，需要标准的json格式.');
                                }
                            }
                        }
                    };
                    for (var menu_type in this.fields_view.toolbar){
                        if (this.fields_view.toolbar[menu_type] && this.fields_view.toolbar[menu_type].length > 0){
                            remove_menus(this.fields_view.toolbar, menu_type);
                        }
                    }
                    this.sidebar.add_toolbar(this.fields_view.toolbar);
                }
                this.sidebar.add_items('other', _.compact([
                    self.is_action_enabled('delete') && { label: _t('Delete'), callback: self.on_button_delete },
                    self.is_action_enabled('create') && { label: _t('Duplicate'), callback: self.on_button_duplicate }
                ]));
            }
            this._super.apply(this, arguments);
        }
    });

    /******************************
    * 设置form中One2Many的列表一页最多显示15条记录
    *******************************/
/*    instance.web.form.One2ManyListView.include({
        init: function (parent, dataset, view_id, options) {
            this._limit = 15 ;
            this._super.apply(this, arguments);
        }
    });*/

    /******************************
    * 设置form中Many2Many的列表一页最多显示15条记录
    *******************************/
/*    instance.web.form.Many2ManyListView.include({
        init: function (parent, dataset, view_id, options) {
            this._limit = 15 ;
            this._super.apply(this, arguments);
        }
    });*/

    /******************************
    * 修正在form中One2Many的可编辑列表中点击输入框时,偶尔会出现数据错位的问题
    *******************************/
    instance.web.form.One2ManyListView.include({
        _on_form_blur: function () {
            if (this.__ignore_blur) {
                this.__ignore_blur = false;
                return;
            }
            // FIXME: why isn't there an API for this?
            if (this.editor.form.$el.hasClass('oe_form_dirty')) {
                this.ensure_saved();
                return;
            }
            //这里注释下面一行,原因不明...
            //this.cancel_edition();
        },
    });

    //改写我的ODOO账户菜单(菜单翻译未完成)
    instance.web.UserMenu.include({
        on_menu_account: function() {
            var self = this;
            var action = {
                type: 'ir.actions.client',
                tag: 'change_password',
                target: "new",
                params: {}
            };
            self.getParent().action_manager.do_action(action);
        },
    });

    //解决IE无法注销，并报js错误的问题
    instance.web.Cordova.include({
        // send a message to cordova
        send: function(message) {
            function inIframe(){
                try {
                    if (window.self instanceof openerp.Class) return false;
                    return window.self !== window.top;
                } catch (e) {
                    return true;
                }
            }
            if (inIframe()) {
                window.parent.postMessage(message,'file://');
            }
        },
    })


    //menu_click传入参数
    //当needaction为object时，借用needaction参数传入action参数
    //实现从某个按钮跳入某view中，并且传入参数(如呼叫中心来电号码点击跳转到查询页面)
    instance.web.WebClient.include({
        on_menu_action: function(options) {
            var self = this;
            return this.menu_dm.add(this.rpc("/web/action/load", { action_id: options.action_id }))
                .then(function (result) {
                    return self.action_mutex.exec(function() {
                        if (options.needaction) {
                            result.context = new instance.web.CompoundContext(result.context, {
                                search_default_message_unread: true,
                                search_disable_custom_filters: true,
                            });
                            if (typeof options.needaction == 'object'){
                                _.extend(result, options.needaction);
                            }
                        }
                        var completed = $.Deferred();
                        $.when(self.action_manager.do_action(result, {
                            clear_breadcrumbs: true,
                            action_menu_id: self.menu.current_menu,
                        })).fail(function() {
                            self.menu.open_menu(options.previous_menu_id);
                        }).always(function() {
                            completed.resolve();
                        });
                        setTimeout(function() {
                            completed.resolve();
                        }, 2000);
                        // We block the menu when clicking on an element until the action has correctly finished
                        // loading. If something crash, there is a 2 seconds timeout before it's unblocked.
                        return completed;
                    });
                });
            }
    });
    //所有的readonly的字段都可以保存
    instance.web.FormView.include({
        _process_save: function(save_obj) {
            var self = this;
            var prepend_on_create = save_obj.prepend_on_create;
            try {
                var form_invalid = false,
                    values = {},
                    first_invalid_field = null,
                    readonly_values = {};
                for (var f in self.fields) {
                    if (!self.fields.hasOwnProperty(f)) { continue; }
                    f = self.fields[f];
                    if (!f.is_valid()) {
                        form_invalid = true;
                        if (!first_invalid_field) {
                            first_invalid_field = f;
                        }
                    } else if (f.name !== 'id' && (!self.datarecord.id || f._dirty_flag)) {
                        values[f.name] = f.get_value();
                    }else if (f.name == 'write_date'){
                        values[f.name] = f.get_value();
                    }
                }
                // Heuristic to assign a proper sequence number for new records that
                // are added in a dataset containing other lines with existing sequence numbers
                if (!self.datarecord.id && self.fields.sequence &&
                    !_.has(values, 'sequence') && !_.isEmpty(self.dataset.cache)) {
                    // Find current max or min sequence (editable top/bottom)
                    var current = _[prepend_on_create ? "min" : "max"](
                        _.map(self.dataset.cache, function(o){return o.values.sequence})
                    );
                    values['sequence'] = prepend_on_create ? current - 1 : current + 1;
                }
                if (form_invalid) {
                    self.set({'display_invalid_fields': true});
                    first_invalid_field.focus();
                    self.on_invalid();
                    return $.Deferred().reject();
                } else {
                    self.set({'display_invalid_fields': false});
                    var save_deferral;
                    if (!self.datarecord.id) {
                        // Creation save
                        save_deferral = self.dataset.create(values, {readonly_fields: readonly_values}).then(function(r) {
                            return self.record_created(r, prepend_on_create);
                        }, null);
                    } else if (_.isEmpty(values)) {
                        // Not dirty, noop save
                        save_deferral = $.Deferred().resolve({}).promise();
                    } else {
                        // Write save
                        save_deferral = self.dataset.write(self.datarecord.id, values, {readonly_fields: readonly_values}).then(function(r) {
                            return self.record_saved(r);
                        }, null);
                    }
                    return save_deferral;
                }
            } catch (e) {
                console.error(e);
                return $.Deferred().reject();
            }
        },
    });
    /*  这个扩展用于实现对与分组特别多的情况 在分组的 context 里面加上 'order':'desc' 因为 odoo默认的是正序的排列 所以想要倒序就加一个参数就好了。 */
    instance.web.ListView.Groups.include({
         render: function (post_render) {
                var self = this;
                var $el = $('<tbody>');
                this.elements = [$el[0]];
                this.datagroup.list(
                    _(this.view.visible_columns).chain()
                        .filter(function (column) { return column.tag === 'field';})
                        .pluck('name').value(),
                    function (groups) {
                        if (self.datagroup.context.order!==undefined && self.datagroup.context.order=='desc'){
                            var groups=groups.reverse();
                        }
                        self.view.$pager.find('.oe_pager_group').hide();
                        self.view.$pager.find('.oe_list_pager_state').text(self.view._limit ? self.view._limit : '∞');
                        $el[0].appendChild(
                            self.render_groups(groups));
                        if (post_render) { post_render(); }
                    }, function (dataset) {
                        self.render_dataset(dataset).then(function (list) {
                            self.children[null] = list;
                            self.elements =
                                [list.$current.replaceAll($el)[0]];
                            self.setup_resequence_rows(list, dataset);
                        }).always(function() {
                            if (post_render) { post_render(); }
                        });
                    });
                return $el;
            },
    });
    instance.web.ListView.List.include({
        // 利用is_pop　字段來控制　是否　需要在點擊記錄的時候弹出新的窗口以便于编辑.有利于减少操作. 如果
        //使用的时候 就直接在 想要使用这个功能的的tree视图上加上一个属性 is_pop='true'
        row_clicked: function (e, view) {
            if (this.view.fields_view!==undefined &&this.view.fields_view.arch.attrs &&
                this.view.fields_view.arch.attrs.is_pop=='true' ) {
                this.view.do_action({
                    type: 'ir.actions.act_window',
                    res_model: this.view.model,
                    view_mode: 'form',
                    view_type: 'form',
                    views: [[false, 'form']],
                    res_id: this.dataset.ids[this.dataset.index],
                    target: 'new',
                }, {
                    on_reverse_breadcrumb: function () {
                        self.reload();
                    }
                });
            }else {
               this._super.apply(this, arguments);
            }
        },


        //重载render函数,实现列表视图记住勾选,刷新后继续保留
        render: function () {
            this.$current.empty().append(
                QWeb.render('ListView.rows', _.extend({
                    render_cell: function () {
                        return self.render_cell.apply(self, arguments);
                    }
                }, this)));
            //this.$current.undelegate( "click" );
            //tree页面才有action
            if (this.view.ViewManager.action) {
                var action_id = this.view.ViewManager.action.id;
                var ids_name = 'select_action_ids_' + action_id;
                var has_delete = false;
                if (localStorage.getItem(ids_name)) {
                    var ids_map = JSON.parse(localStorage.getItem(ids_name));
                    var ids = [];
                    var records = [];
                    for (var id in ids_map) {
                        var $select_tr = this.$current.find('[data-id=' + id + ']');
                        var $find_tr = $select_tr.find('.oe_list_record_selector');
                        if ($find_tr.length) {
                            $find_tr.addClass('th_selected');
                            $find_tr.find('input[type=checkbox]').prop('checked', true);
                            ids.push(ids_map[id]);
                            records.push(this.view.records.get(ids_map[id]).attributes)
                        }
                        else {
                            delete ids_map[id];
                            has_delete = true;
                        }
                    }
                    $(this.view.groups).trigger(
                        'selected', [ids, records]);
                    if (has_delete) {
                        localStorage.setItem(ids_name, JSON.stringify(ids_map));
                    }
                    //                $select_tr = this.$current.find('[data-id=' + selected_id + ']');
                    //                $select_tr.find('.oe_list_record_selector').addClass('th_selected');
                    //                $select_tr.parent().data('selectedId', selected_id);

                }
                var self = this;
                //单击行弹出层来操作无法
                //            this.$current.delegate('tr', 'click', function (e) {
                //                var row_id = self.row_id(e.currentTarget);
                //                if (row_id) {
                //                    e.stopPropagation();
                //                    if (!self.dataset.select_id(row_id)) {
                //                        throw new Error(_t("Could not find id in dataset"));
                //                    }
                //                    console.log(row_id);
                //                    instance.session.rpc("/web/action/load", { action_id: "base.action_res_users_my" }).done(function(result) {
                //                        result.res_id = instance.session.uid;
                //                        instance.client.action_manager.do_action(result);
                //                    });
                //                    return;
                //                    self.row_clicked(e);
                //                }
                //            });
                //            this.$current.find('.oe_list_record_selector').click(function(){
                //                var selectedId = $(this.parentNode.parentNode).data('selectedId');
                //                if (selectedId){
                //                    $th = self.$current.find('[data-id=' + selectedId + '] > th.oe_list_record_selector');
                //                    $th.removeClass('th_selected');
                //                }
                //                var checked = $(this).find('input[type=checkbox]').attr("checked");
                //                var id = $(this.parentNode).data('id');
                //                $(this.parentNode.parentNode).data('selectedId', id);
                //                //console.log(this.parentNode.rowIndex);
                //                var select_action_ids = localStorage.getItem(ids_name) || '{}';
                //                var ids_map = JSON.parse(select_action_ids);
                //                if (checked){
                //                    ids_map[id] = id;
                //                }
                //                else{
                //                    delete ids_map[id];
                //                }
                //                localStorage.setItem(ids_name, JSON.stringify(ids_map));
                //                $(this).addClass('th_selected');
                //            });
                this.$current.find('.oe_list_record_selector input[type=checkbox]').change(function () {
                    var selectedId = $(this.parentNode.parentNode.parentNode).data('selectedId');
                    if (selectedId) {
                        $th = self.$current.find('[data-id=' + selectedId + '] > th.oe_list_record_selector');
                        $th.removeClass('th_selected');
                    }
                    var checked = $(this).prop("checked");
                    var id = $(this.parentNode.parentNode).data('id') * 1;
                    //$(this.parentNode.parentNode).data('selectedId', id);
                    //console.log(this.parentNode.rowIndex);
                    var select_action_ids = localStorage.getItem(ids_name) || '{}';
                    var ids_map = JSON.parse(select_action_ids);
                    if (checked) {
                        ids_map[id] = id;
                    }
                    else {
                        delete ids_map[id];
                    }
                    localStorage.setItem(ids_name, JSON.stringify(ids_map));
                    $(this).addClass('th_selected');
                });
            }
            this.pad_table_to(4);
        }
    });

    //系统自带模块 消息模块可以显示图片
    if (openerp.im_chat) {
        openerp.im_chat.ConversationManager.include({
            on_notification: function(notification) {
                var self = this;
                var channel = notification[0];
                var message = notification[1];
                var regex_uuid = new RegExp(/(\w{8}(-\w{4}){3}-\w{12}?)/g);

                // Concern im_chat : if the channel is the im_chat.session or im_chat.status, or a 'private' channel (aka the UUID of a session)
                if((Array.isArray(channel) && (channel[1] === 'im_chat.session' || channel[1] === 'im_chat.presence')) || (regex_uuid.test(channel))){
                    // message to display in the chatview
                    if (message.type === "message" || message.type === "meta" || message.type=="voice" || message.type=="image") {
                        self.received_message(message);
                    }
                    // activate the received session
                    if(message.uuid){
                        this.apply_session(message);
                    }
                    // user status notification
                    if(message.im_status){
                        self.trigger("im_new_user_status", [message]);
                    }
                }
            },


        });
        openerp.im_chat.Conversation.include({
            render_messages: function () {
                var self = this;
                var res = {};
                var last_date_day, last_user_id = -1;
                _.each(this.get("messages"), function (current) {
                    // add the url of the avatar for all users in the conversation
                    current.from_id[2] = openerp.session.url(_.str.sprintf("/im_chat/image/%s/%s", self.get('session').uuid, current.from_id[0]));
                    var date_day = current.create_date.split(" ")[0];
                    if (date_day !== last_date_day) {
                        res[date_day] = [];
                        last_user_id = -1;
                    }
                    last_date_day = date_day;
                    if (current.type == "message" || current.type == 'image' ||current.type == 'voice' ) { // traditionnal message
                        if (last_user_id === current.from_id[0]) {
                            _.last(res[date_day]).push(current);
                        } else {
                            res[date_day].push([current]);
                        }
                        last_user_id = current.from_id[0];
                    } else { // meta message
                        res[date_day].push([current]);
                        last_user_id = -1;
                    }
                });
                // render and set the content of the chatview
                this.$('.oe_im_chatview_content_bubbles').html($(openerp.qweb.render("im_chat.Conversation_content", {"list": res})));
                this._go_bottom();
            },
        })
    }
    //扩展高级查询字符串查询条件
    instance.web.search.ExtendedSearchProposition.Char = instance.web.search.ExtendedSearchProposition.Field.extend({
        template: 'SearchView.extended_search.proposition.char',
        operators: [
            {value: "ilike", text: _lt("contains")},
            {value: "not ilike", text: _lt("doesn't contain")},
            {value: "=", text: _lt("is equal to")},
            {value: "!=", text: _lt("is not equal to")},
            {value: ">", text: _lt("greater than")},
            {value: "<", text: _lt("less than")},
            {value: ">=", text: _lt("greater or equal than")},
            {value: "<=", text: _lt("less or equal than")},
            {value: "∃", text: _lt("is set")},
            {value: "∄", text: _lt("is not set")}
        ],
        get_value: function() {
            return this.$el.val();
        }
    });

    //实现tree视图里的'create', 'edit', 'delete'属性可以用action中的context常量来组成一个python布尔表达式
    instance.web.View.include({
        is_action_enabled: function(action) {
            var attrs = this.fields_view.arch.attrs;
            var result = (action in attrs) ? attrs[action] : 'true';
            if (result != 'false' && result != 'true'){
                var expression = py.parse(py.tokenize(result));
                if (this.ViewManager && this.ViewManager.action && this.ViewManager.action.context[action] !==undefined){
                    result = py.evaluate(expression, this.ViewManager.action.context).toJSON();
                }else{
                    result = 'true';
                }
            }else{
                result = JSON.parse(result);
            }
            return result;
        },
    });
})();


